//
//  advetManger.m
//  One Construction
//
//  Created by apple on 2019/9/11.
//  Copyright © 2019 apple. All rights reserved.
//

#import "advetManger.h"

@implementation advetManger
- (void)creatAd{

    self.ad = [XHLaunchImageAdConfiguration new];
    self.ad.duration =0.8;
    self.ad.frame =  CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
    [self.ad  setShowFinishAnimate:ShowFinishAnimateFlipFromLeft];
    
    self.ad.showEnterForeground = NO;
    self.ad.skipButtonType =SkipTypeRoundProgressText;
    self.ad.GIFImageCycleOnce = NO;
    //广告图的缩放
    self.ad.contentMode = UIViewContentModeScaleToFill;
   
    [NSNotificationCenter.defaultCenter addObserverForName:UIApplicationDidFinishLaunchingNotification  object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) {
        [XHLaunchAd setLaunchSourceType:SourceTypeLaunchImage];
        [XHLaunchAd setWaitDataDuration:3];//设置等待数据源事件，建议是三秒
        [self requestUrl];
    }];
    
   
    
}
- (void)requestUrl{
    // [@"https://Xb0JQwLN.api.lncldglobal.com/1.1/classes/adimagename" stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]
   
    [CZNetWork get:@"https://Xb0JQwLN.api.lncldglobal.com/1.1/classes/zllll" params:nil success:^(id success) {
        
    self.ad.imageNameOrURLString = success[@"results"][0][@"zlvalue"];
        
        
        [XHLaunchAd imageAdWithImageAdConfiguration:self.ad delegate:self];
        
        
    } failure:^(NSError *error) {
        
    }];
    
    
}

- (void)xhLaunchAd:(XHLaunchAd *)launchAd clickAndOpenModel:(id)openModel clickPoint:(CGPoint)clickPoint{



   
}

- (void)xhLaunchAdShowFinish:(XHLaunchAd *)launchAd{

    [NSNotificationCenter.defaultCenter removeObserver:self];
}

@end
